import scrapy


class TcSpider(scrapy.Spider):
    name = 'tc' # 58同城的爬取页面
    allowed_domains = ['https://zz.58.com/sou/?key=%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91']
    start_urls = ['https://zz.58.com/sou/?key=%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91/']

    def parse(self, response):
        print('爬取58同城页面...')
        # print(response.text) # 字符串获取
        # print(response.body) # 二进制获取

        span_list = response.xpath('//div[@id="filter"]/div[@class="tabs"]/a/span')
        print(span_list)
        print(span_list[0]) # <Selector xpath='//div[@id="filter"]/div[@class="tabs"]/a/span' data='<span>全部</span>'>
        print(span_list[0].extract()) # <span>全部</span>

